#include <stdio.h>

int main()
{
    int n, k, i = 0, j = 0;

    int a[9][9] = {0};
    a[0][0] = 1;
    scanf("%d", &n);

    for (k = 1; k < n * n;)
    {
        while (++j < n && a[i][j] == 0)
            a[i][j] = ++k;
        --j;

        while (++i < n && a[i][j] == 0)
            a[i][j] = ++k;
        --i;

        while (--j >= 0 && a[i][j] == 0)
            a[i][j] = ++k;
        ++j;

        while (--i >= 0 && a[i][j] == 0)
            a[i][j] = ++k;
        ++i;
    }

    for (i = 0; i < n; i++)
        for (j = 0; j < n; j++)
        {
            printf("%3d", a[i][j]);
            if (j == n - 1)
                printf("\n");
        }

    return 0;
}